home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / tclMotif-1.4 / extern_widgets / html.expand < prev    next >
Encoding:
Text File  |  1995-06-29  |  1.2 KB  |  50 lines

  1.  
  2.  
  3.     /* test of html expand code insert */
  4.     /* THIS CODE IS PROBABLY WRONG */
  5.  
  6.     if (XtIsSubclass(w, htmlWidgetClass)) {
  7.     /*
  8.      * now we can coerce the call_data into our widget type  -
  9.      * that is, if we can figure it out from the info above.
  10.      * e.g. assume that we have a WbAnchorCallbackData callback
  11.      */
  12.     WbAnchorCallbackData *c_data = (WbAnchorCallbackData *) call_data;    
  13.  
  14.     /*
  15.      * examine each possible field of the callback struct in turn
  16.      */
  17.     if (length == strlen("element_id") && 
  18.         strncmp(value, "element_id", length) == 0) {
  19.  
  20.         /*
  21.          * this is an int value in this field, so convert to string
  22.          */
  23.         static char buf[16];
  24.  
  25.         sprintf(buf, "%d", c_data->element_id);
  26.         return buf;
  27.     } else
  28.     
  29.     if (length == strlen("text") &&
  30.         strncmp(value, "text", length) == 0) {
  31.  
  32.         /*
  33.          * this is a string, so just return it
  34.          */
  35.         return c_data->text;
  36.     } else
  37.  
  38.     if (length == strlen("href") &&
  39.         strncmp(value, "href", length) == 0) {
  40.  
  41.         return c_data->href;
  42.     } else {
  43.         /*
  44.          * this occurs when the field asked for is not supported -
  45.              * often caused by a typo in the user's program
  46.          */
  47.         return "ERROR in substitution";
  48.     }
  49.     }
  50.